﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Erp.Migrations
{
    /// <inheritdoc />
    public partial class modify_table_InboundRec : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_InboundDetls_MaterialInfos_MaterialInfoId",
                schema: "Erp",
                table: "InboundDetls");

            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecs_MaterialSuppliers_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecs_MaterialWhses_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "InboundType",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.RenameColumn(
                name: "OrderNo",
                schema: "Erp",
                table: "InboundRecs",
                newName: "InvChgTypeName");

            migrationBuilder.RenameColumn(
                name: "MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "MatlWhseId");

            migrationBuilder.RenameColumn(
                name: "MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "MatlSplerId");

            migrationBuilder.RenameColumn(
                name: "InboundDatetime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "PurchaseTime");

            migrationBuilder.RenameIndex(
                name: "IX_InboundRecs_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "IX_InboundRecs_MatlWhseId");

            migrationBuilder.RenameIndex(
                name: "IX_InboundRecs_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "IX_InboundRecs_MatlSplerId");

            migrationBuilder.RenameColumn(
                name: "MaterialInfoId",
                schema: "Erp",
                table: "InboundDetls",
                newName: "MatlInfoId");

            migrationBuilder.RenameIndex(
                name: "IX_InboundDetls_MaterialInfoId",
                schema: "Erp",
                table: "InboundDetls",
                newName: "IX_InboundDetls_MatlInfoId");

            migrationBuilder.AddColumn<decimal>(
                name: "DiscRate",
                schema: "Erp",
                table: "InboundRecs",
                type: "numeric(18,2)",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "InboundTime",
                schema: "Erp",
                table: "InboundRecs",
                type: "timestamp without time zone",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "InvChgTypeCode",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<DateTime>(
                name: "InvoicingTime",
                schema: "Erp",
                table: "InboundRecs",
                type: "timestamp without time zone",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Invono",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "OrdNo",
                schema: "Erp",
                table: "InboundRecs",
                type: "text",
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "PurcAmt",
                schema: "Erp",
                table: "InboundRecs",
                type: "numeric(18,4)",
                nullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundDetls_MaterialInfos_MatlInfoId",
                schema: "Erp",
                table: "InboundDetls",
                column: "MatlInfoId",
                principalSchema: "Erp",
                principalTable: "MaterialInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecs_MaterialSuppliers_MatlSplerId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MatlSplerId",
                principalSchema: "Erp",
                principalTable: "MaterialSuppliers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecs_MaterialWhses_MatlWhseId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MatlWhseId",
                principalSchema: "Erp",
                principalTable: "MaterialWhses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_InboundDetls_MaterialInfos_MatlInfoId",
                schema: "Erp",
                table: "InboundDetls");

            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecs_MaterialSuppliers_MatlSplerId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropForeignKey(
                name: "FK_InboundRecs_MaterialWhses_MatlWhseId",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "DiscRate",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "InboundTime",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "InvChgTypeCode",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "InvoicingTime",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "Invono",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "OrdNo",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.DropColumn(
                name: "PurcAmt",
                schema: "Erp",
                table: "InboundRecs");

            migrationBuilder.RenameColumn(
                name: "PurchaseTime",
                schema: "Erp",
                table: "InboundRecs",
                newName: "InboundDatetime");

            migrationBuilder.RenameColumn(
                name: "MatlWhseId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "MaterialWhseId");

            migrationBuilder.RenameColumn(
                name: "MatlSplerId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "MaterialSupplierId");

            migrationBuilder.RenameColumn(
                name: "InvChgTypeName",
                schema: "Erp",
                table: "InboundRecs",
                newName: "OrderNo");

            migrationBuilder.RenameIndex(
                name: "IX_InboundRecs_MatlWhseId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "IX_InboundRecs_MaterialWhseId");

            migrationBuilder.RenameIndex(
                name: "IX_InboundRecs_MatlSplerId",
                schema: "Erp",
                table: "InboundRecs",
                newName: "IX_InboundRecs_MaterialSupplierId");

            migrationBuilder.RenameColumn(
                name: "MatlInfoId",
                schema: "Erp",
                table: "InboundDetls",
                newName: "MaterialInfoId");

            migrationBuilder.RenameIndex(
                name: "IX_InboundDetls_MatlInfoId",
                schema: "Erp",
                table: "InboundDetls",
                newName: "IX_InboundDetls_MaterialInfoId");

            migrationBuilder.AddColumn<int>(
                name: "InboundType",
                schema: "Erp",
                table: "InboundRecs",
                type: "integer",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundDetls_MaterialInfos_MaterialInfoId",
                schema: "Erp",
                table: "InboundDetls",
                column: "MaterialInfoId",
                principalSchema: "Erp",
                principalTable: "MaterialInfos",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecs_MaterialSuppliers_MaterialSupplierId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MaterialSupplierId",
                principalSchema: "Erp",
                principalTable: "MaterialSuppliers",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InboundRecs_MaterialWhses_MaterialWhseId",
                schema: "Erp",
                table: "InboundRecs",
                column: "MaterialWhseId",
                principalSchema: "Erp",
                principalTable: "MaterialWhses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
